package com.itwn.portal.mapper;

import com.itwn.portal.entity.User;

import com.itwn.portal.vo.UserRecordVo;

import com.itwn.portal.vo.BookcaseVo;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(User record);

    User selectByPrimaryKey(Integer id);

    List<User> selectAll();

    int updateByPrimaryKey(User record);

    @Select("select * from t_user where username = #{username}")
    User selectUserByName(String username);

    List<UserRecordVo> selectPersonRecord(@Param("uid") Integer uid);

    List<BookcaseVo> selectBookCase(Integer id);

    /**
     * 用户投票后月票数减去1
     * @param uid
     */
    @Update("update t_user set month_ticket = month_ticket-1 where id=#{uid}")
    void delMTicket(@Param("uid")Integer uid);
    void updateUserInfo(@Param("id") Integer id, @Param("nickname") String nickname,@Param("sex") Byte sex,@Param("age") Integer age);

    void updatePassword(@Param("id") Integer id,@Param("newPass") String newPass);

    void updateReadPoint(@Param("uid") Integer id, @Param("ReadPoint") int i);

    void updatePointTicket(@Param("uid") Integer id,@Param("PointTicket") int i);

    void updateAvater(@Param("uid") Integer uid,@Param("avatar") String avatar);
}